﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO.WaiGaoQiao;
using System.Data;

namespace Model.WaiGaoQiao
{
    /// <summary>
    /// 劳保调出
    /// </summary>
    public class Work_OutStorageDetailedInfo
    {
          DataAccessWork_OutStorage DAS;
      
        //构造函数
          public Work_OutStorageDetailedInfo() { DAS = new DataAccessWork_OutStorage(); }
        #region -----------------------劳保调出字段-------------------------
        /// <summary>
        /// ID
        /// </summary>
        public int ID { get; set; }
        /// <summary>
        /// 调出日期
        /// </summary>
        public DateTime OutDt { get; set; }
        /// <summary>
        /// 劳保物品id
        /// </summary>
        public int Article_ID { get; set; }
        /// <summary>
        /// 物品编号
        /// </summary>
        public string Article_NO { get; set; }
        /// <summary>
        /// 物品名称
        /// </summary>
        public string Article_Name { get; set; }
        /// <summary>
        /// 劳保物品规格
        /// </summary>
        public string Article_Unit { get; set; }
      /// <summary>
        /// 数量
        /// </summary>
        public int Count { get; set; }
        /// <summary>
        /// 操作人
        /// </summary>
        public string Operate { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 记录日期
        /// </summary>
        public DateTime RecordDateTime { get; set; }
        /// <summary>
        /// 订单编号
        /// </summary>
        public string OrderNo { get; set; }
        #endregion

        /// <summary>
        /// 生成批量输入编号
        /// </summary>
        /// <returns></returns>
        public virtual string BuliderOrderNo()
        {
            return DAS.GetOutStorageDetailedOrderNo();
        }
        /// <summary>
        /// 获取劳保物资调出数量
        /// </summary>
        /// <returns></returns>
        public int GetCountOutStorageDetailed(string Condition)
        {
            return DAS.GetCountOutStorageDetailed(Condition);
        }


        /// <summary>
        /// 保存劳保物资调出
        /// </summary>
        /// <param name="idab"></param>
        /// <returns></returns>
        public int SaveOutStorageDetailed(Work_OutStorageDetailedInfo sdiDetail)
        {
            object[] idpara = new object[] {sdiDetail.ID,sdiDetail.OutDt, sdiDetail.Article_ID,sdiDetail.Article_Name, sdiDetail.Article_NO,
                                            sdiDetail.Article_Unit, sdiDetail.Count,sdiDetail.Operate,
                                            sdiDetail.RecordDateTime, sdiDetail.Remark,sdiDetail.OrderNo };
            return DAS.SaveOutStorageDetailed(idpara);
        }

        /// <summary>
        /// 获取劳保物资调出不分页
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public IList<Work_OutStorageDetailedInfo> GetAllOutStorageDetailed(string condition)
        {
            IList<Work_OutStorageDetailedInfo> Idalist = new List<Work_OutStorageDetailedInfo>();
            DataSet ds = DAS.GetAllOutStorageDetailed(condition);
            Work_OutStorageDetailedInfo ideinfo;
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ideinfo = new Work_OutStorageDetailedInfo()
                {
                    ID = Convert.ToInt32(item[0]),
                    OutDt = Convert.ToDateTime(item[1]),
                    Article_ID = Convert.ToInt32(item[2]),
                    Article_Name = Convert.ToString(item[3]),
                    Article_NO = Convert.ToString(item[4]),
                    Article_Unit = item[5].ToString(),
                    Count = Convert.ToInt32(item[6]),
                    Operate = item[7].ToString(),
                    Remark = item[8].ToString(),
                    RecordDateTime = Convert.ToDateTime(item[9]),
                    OrderNo = item[10].ToString()
                };
                Idalist.Add(ideinfo);
            }
            return Idalist;
        }


        /// <summary>
        /// 根据ID获取劳保物资调出实体类
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public Work_OutStorageDetailedInfo GetAllOutStorageDetailed(int Id)
        {
            DataRow item = DAS.GetAllOutStorageDetailed(" And id=" + Id).Tables[0].Rows[0];
            Work_OutStorageDetailedInfo ideinfo = new Work_OutStorageDetailedInfo()
            {
                ID = Convert.ToInt32(item[0]),
                OutDt = Convert.ToDateTime(item[1]),
                Article_ID = Convert.ToInt32(item[2]),
                Article_Name = Convert.ToString(item[3]),
                Article_NO = Convert.ToString(item[4]),
                Article_Unit = item[5].ToString(),
                Count = Convert.ToInt32(item[6]),
                Operate = item[7].ToString(),
                Remark = item[8].ToString(),
                RecordDateTime = Convert.ToDateTime(item[9]),
                OrderNo = item[10].ToString()
            };
            return ideinfo;
        }


        /// <summary>
        /// 获取劳保物资调出分页
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public IList<Work_OutStorageDetailedInfo> GetAllOutStorageDetailed(string condition, int pagesize, int startindex)
        {
            IList<Work_OutStorageDetailedInfo> Idalist = new List<Work_OutStorageDetailedInfo>();
            DataSet ds = DAS.GetAllOutStorageDetailed(condition, pagesize, startindex);
            Work_OutStorageDetailedInfo ideinfo;
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ideinfo = new Work_OutStorageDetailedInfo()
                {
                    ID = Convert.ToInt32(item[0]),
                    OutDt=Convert.ToDateTime(item[1]),
                    Article_ID = Convert.ToInt32(item[2]),
                    Article_Name = Convert.ToString(item[3]),
                    Article_NO = Convert.ToString(item[4]),
                    Article_Unit = item[5].ToString(),
                    Count = Convert.ToInt32(item[6]),
                    Operate = item[7].ToString(),
                    Remark = item[8].ToString(),
                    RecordDateTime = Convert.ToDateTime(item[9]),
                    OrderNo = item[10].ToString()
                };
                Idalist.Add(ideinfo);
            }
            return Idalist;
        }



        /// <summary>
        /// 删除劳保物资调出
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public int DeleteOutStorageDetailed(int Id)
        {
            return DAS.DeleteOutStorageDetailed(" Id=" + Id);
        }
        /// <summary>
        /// 验证出库数量
        /// </summary>
        /// <param name="article_id"></param>
        /// <param name="article_unit"></param>
        /// <returns></returns>
        public int ValidateOutStorage(string article_id, string article_unit)
        {
            return DAS.ValidateOutStorage(article_id, article_unit);
        }
    }
}
